//返回顶部
var t = document.querySelector("#toTop");

window.onscroll = function() {
	if(document.documentElement.scrollTop > 800 || document.body.scrollTop > 800) {
		t.style.display = "block";
	} else {
		t.style.display = "none";
	}
	
	var navbar = document.querySelector(".navbar");
	if(document.documentElement.scrollTop > 85 || document.body.scrollTop > 85) {
		navbar.style.top = "0px";
	} else {
		navbar.style.top = "85px";
	}

}
t.addEventListener('click', function() {
	window.scrollTo({
		top: 0,
		behavior: 'smooth'
	})
})







//点击客服

var kefu = document.querySelector("#kefu");

var k_content = document.querySelector(".kefu-content");

var k_x = document.querySelector("#x");


kefu.addEventListener("click" ,function(){
	k_content.style.display = "block";
})

k_x.addEventListener("click" , function(){
	k_content.style.display = "none";
})




//点击邮件

var body = document.querySelector("body");

var email_content = document.querySelector(".wapper");

var email = document.querySelector("#email");

var email_x = document.querySelector("#em-x");

email.addEventListener("click" , function(){
	email_content.style.display = "block";
	email_content.style.backgroundColor = "rgba(39, 39, 39, 0.57)";
})

email_x.addEventListener("click" , function(){
	email_content.style.display = "none";
})



//轮播
var swiper = new Swiper('.swiper-container', {
	pagination: {
		el: '.swiper-pagination',
	},
	navigation: {
		nextEl: '.swiper-button-next',
		prevEl: '.swiper-button-prev',
	},
	loop: true
});




//硬件软件下滑

var dt_nav_btn = document.querySelectorAll("#dt_nav_btn");

var dt_nav_content = document.querySelectorAll("#dt_nav_content");

//移进事件

for(var i = 0; i < dt_nav_btn.length; i++) {
	dt_nav_btn[i].addEventListener("mouseover", function() {
		this.parentElement.lastElementChild.style.display = 'block';
	})
	//移出事件
	for(var k = 0; k < dt_nav_btn.length; k++) {
		dt_nav_content[k].addEventListener("mouseleave", function() {
			this.parentElement.lastElementChild.style.display = 'none';
		})
	}
}

//登录下滑菜单
var dv_nav_btn = document.querySelectorAll("#dv_nav_btn");

var dv_nav_content = document.querySelectorAll("#dv_nav_content");

//移进事件

for(var i = 0; i < dv_nav_btn.length; i++) {
	dv_nav_btn[i].addEventListener("mouseover", function() {
		console.log("移进了");
		for(var k = 0; k < dv_nav_content.length; k++) {
			dv_nav_content[k].style.display = "block";
		}
	});
	//移出事件
	for(var k = 0; k < dv_nav_content.length; k++) {
		dv_nav_content[k].addEventListener("mouseleave", function() {
			console.log("移出了");
			this.style.display = "none";
		})
	}

}

//请求json数据
var vm = new Vue({
	el: "#app",
	data: {
		message: "正在请求数据!"
	},

	mounted() {
		axios
			.get('json/json.json')
			.then(response => (this.message = response.data.urls))
			.catch(function(error) {
				console.log(error)
			})
	}

})

//底部点击

var up = document.querySelectorAll("#f-n");

var down = document.querySelectorAll(".f-i-s-t");

console.log(up);
console.log(down);

for(var asd = 0; asd < up.length; asd++) {
	up[asd].bool = true;
	//获取下标
	up[asd].index = asd;
	up[asd].addEventListener("click", function() {
		if(this.bool) {
			for(var as = 0; as < up.length; as++) {
				down[this.index].style.display = "block";
				up[this.index].style.transform = "rotateZ(180deg)";

			}
		} else {
			for(var as = 0; as < up.length; as++) {
				down[this.index].style.display = "none";
				up[this.index].style.transform = "rotateZ(0deg)";
			}
		}
		this.bool = !this.bool;
	})
}






